<%--
  Created by IntelliJ IDEA.
  User: 王润
  Date: 2017/7/26
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <title>人事调度查询</title>
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" type="text/css" href="../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" type="text/css" href="/css/base/base.css?20201106.1"/>
    <script src="/js/common/language.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .main_title li {
            height: 28px;
            line-height: 28px;
            display: inline-block;
            float: left;
            font-family: Microsoft yahei,Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;
            font-size: 14px;
            margin-left: 20px;
            margin-top: 6px;
            cursor: pointer;
        }

        .head {
            margin-top: 10px;
            height: 33px;
            border-bottom: 1px solid black;
        }

        .head .title {
            margin-left: 22px;
        }

        .head span {
            float: none;
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }

        label select {
            width: 130px;
            padding-left: 10px;
            height: 32px;
            left: 20px;
        }

        .fl input {
            padding: 0 10px;
            width: 130px
        }

        #pagediv #pageTbody input[name="checkbox"] {
            display: inline-block;
        }

        .pagediv .page-bottom-outer-layer table td:last-child {
            font-weight: normal;
            overflow: hidden;
            white-space: pre;
            height: 40px;
            padding: 4px;
            box-sizing: border-box;
            text-overflow: ellipsis;
            font-size: 11pt;
            text-align: left;
            border-right: 1px solid #ddd;
        }

        .sel li {
            line-height: 24px;
            color: #000;
        }

        #list img {
            margin-top: -2px;
            margin-left: 0;
        }

        .pBeforeLa p {
            position: relative;
        }

        .inp_sel {
            width: 100%;
            padding-top: 32px;
            margin-bottom: 65px;
            font-size:16px;
        }

        .inp_sel input {
            margin-left: 10px;
            width: 170px;
            border: 1px solid rgb(204, 204, 204);
            border-radius: 5px;
            padding-left: 5px;
        }

        .inp {
            height: 40px;
            float: left;
            margin-left: 20px;
            border-radius: 4px;
        }

        #j_tb tr {
            height: 40px;
            line-height: 40px;
        }

        #j_tb {
            height: 400px;
        }

        select, textarea {
            width: 170px;
            height: 30px;
            line-height: 30px;
            border-radius: 4px;
            margin-right: 10px;
        }

        #checkOut {
            width: 80px;
            height: 30px;
            background: url('../../img/address/shape.png') no-repeat;
            background-color: #2d7de0;
            color: white;
            text-align: center;
            background-position: 11px 7px;
            padding-left: 10px;
            cursor: pointer;
            line-height: 30px;
            margin-top: 10px;
        }

        table input {
            width: 17px;
        }
        .inp a {
            font-size: 13px;
        }
    </style>
</head>
<body>
<div class="head" style="border-bottom: 1px solid black">
    <div class="title">
        <img src="/img/commonTheme/theme6/flow_run_title.png">
        <span style="">人员调度查询</span>
    </div>
</div>
<div class="inp_sel">
    <div class="inp">
        项目:
        <select class="project">
            <option>请选择..</option>
        </select>
    </div>
    <div class="inp">
        部门:
        <input type="text" name="" id="deptment" user_id="" value="" style="width: 170px" disabled>
        <a href="javascript:;" id="selectDept" style="color:#1772c0"><fmt:message code="global.lang.add"/></a>
        <a href="javascript:;" id="clearDept" style="color:#1772c0"><fmt:message code="global.lang.empty"/></a>
    </div>
    <div class="inp">
        职务:
        <select id="jobPosition">
            <option>请选择..</option>
        </select>
    </div>
    <div class="inp">
        岗位:
        <select id="workJob">
            <option>请选择..</option>
        </select>
    </div>

    <div class="inp">
        所在位置:
        <select class="location">
            <option>请选择..</option>
        </select>
    </div>
    <div class="inp">目标人：<input name="" id="userDuser" user_id="" style="width: 170px"
                                disabled/>
        <a href="javascript:;" id="selectUser" style="color:#1772c0"><fmt:message code="global.lang.add"/></a>
        <a href="javascript:;" id="clearUser" style="color:#1772c0"><fmt:message code="global.lang.empty"/></a>
    </div>
    <div class="inp" id="checkOut">查询</div>

</div>
<div class="tab" style="margin-top: 100px">
    <table id="tr_td" style="table-layout: fixed;">
        <thead>
        <tr>
            <td class="th" style="width: 9%;">序号</td>
            <td class="th" style="width: 9%;">姓名</td>
            <td class="th" style="width: 9%;">部门</td>
            <td class="th" style="width: 9%;">职务</td>
            <td class="th" style="width: 9%;">项目</td>
            <td class="th" style="width: 9%;">岗位</td>
            <td class="th" style="width:9%;">所在位置</td>
            <td class="th" style="width: 9%;">调度人</td>
            <td class="th" style="width: 9%;">调度时间</td>
            <td class="th" style="width: 9%;">操作</td>
        </tr>
        </thead>
        <tbody id="j_tb">

        </tbody>
    </table>
    <div class="right" style="margin-right: 6%;">
        <div style="margin: 0 auto;height:50px;width: 97%;" class="clearfix">
            <div id="dbgz_page" class="M-box3">

            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    $(document).on('click','.lookDetail',function () {
        var assessScore = $(this).attr('assessScore');
        $.popWindow("/hrPersonnelScheduling/lookDetails?assessScore="+assessScore);
    });
    $(function () {
//        列表带分页
        var ajaxPageLe = {
            data: {
                page: 1,//当前处于第几页
                pageSize: 20,//一页显示几条
                useFlag: true
            },
            page: function () {
                var me = this;
                $.ajax({
                    url: '/hrPersonnelScheduling/loadHrDispatcherPages',
                    type: 'get',
                    data: me.data,
                    dataType: 'json',
                    success: function (res) {
                        var datas = res.obj;
                        var str = "";

                        function checkInner(obj) {
                            if (obj == "" || typeof (obj) == "undefined") {
                                return " ";
                            } else if (obj.indexOf(",")>0) {
                                var i = obj.indexOf(",");
                                var newObj = obj.substr(i+1);
                                return newObj;
                            } else {
                                return obj;
                            }
                        }

                        function checkInnerUserName(obj,len) {
                            if (obj == "" || typeof (obj) == "undefined") {
                                return "";
                            } else if (len>1) {
                                return obj+"等人";
                            } else {
                                return obj;
                            }
                        }

                        function checkInnerDeptName(obj,len) {
                            if (obj == "" || typeof (obj) == "undefined") {
                                return "";
                            } else if (len>1) {
                                return obj+"等部门";
                            } else {
                                return obj;
                            }
                        }

                        for (var x = 0; x < res.obj.length; x++) {
                            str += " <tr>\n" +
                                "            <td>" + (x+1) + "</td>\n" +
                                "            <td staff=" + res.obj[x]['dispatcherId'] + " id=" + res.obj[x]["userId"] + ">" + checkInnerUserName(res.obj[x]["userName"],res.obj[x]["num"]) + "</td>\n" +
                                "            <td>" + checkInnerDeptName(res.obj[x]["deptName"],res.obj[x]["num"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["jobPositionName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["projectName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["workJobName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["locationAddressName"]) + "</td>\n"+
                                "            <td>" + checkInner(res.obj[x]["createrName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["updateTime"]) + "</td>\n" +
                                "            <td><span class='lookDetail' style='cursor: pointer;color: rgb(51, 161, 232);' assessScore='"+checkInner(res.obj[x]["assessScore"])+"'>查看详情</span></td>\n"  ;
                        }
                        $("#j_tb").html(str);

                        me.pageTwo(res.totleNum, me.data.pageSize, me.data.page);
                    }
                })
            },
            pageTwo: function (totalData, pageSize, indexs) {
                var mes = this;
                $('#dbgz_page').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    jump: true,
                    coping: true,
                    homePage: '',
                    endPage: '',
                    current: indexs || 1,
                    callback: function (index) {
                        mes.data.page = index.getCurrent();
                        mes.page();
                    }
                });
            }
        };
        ajaxPageLe.page();
    });

    function ajaxReAjax(datt) {
        var ajaxPageLe = {
            data: {
                page: 1,//当前处于第几页
                pageSize: 20,//一页显示几条
                useFlag: true
            },
            page: function () {
                var me = this;
                datt['page'] = me.data.page;
                datt['pageSize'] = me.data.pageSize;
                datt['userFlag'] = me.data.useFlag;
                $.ajax({
                    url: '/hrPersonnelScheduling/selectHrDispatcherList',
                    type: 'get',
                    data: datt,
                    dataType: 'json',
                    success: function (res) {
                        var datas = res.obj;
                        var str = "";

                        function checkInner(obj) {
                            if (obj == "" || typeof (obj) == "undefined") {
                                return " ";
                            } else if (obj.indexOf(",")>0) {
                                var i = obj.indexOf(",");
                                var newObj = obj.substr(i+1);
                                return newObj;
                            } else {
                                return obj;
                            }
                        }

                        for (var x = 0; x < res.obj.length; x++) {
                            str += " <tr>\n" +
                                "            <td>" + (x+1) + "</td>\n" +
                                "            <td staff=" + res.obj[x]['dispatcherId'] + " id=" + res.obj[x]["userId"] + ">" + checkInner(res.obj[x]["userName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["deptName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["jobPositionName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["projectName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["workJobName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["locationAddressName"]) + "</td>\n"+
                                "            <td>" + checkInner(res.obj[x]["createrName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["updateTime"]) + "</td>\n" +
                                "            <td></td>\n"  ;
                        }
                        $("#j_tb").html(str);
                        me.pageTwo(res.totleNum, me.data.pageSize, me.data.page);
                    }
                })
            },
            pageTwo: function (totalData, pageSize, indexs) {
                var mes = this;
                $('#dbgz_page').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    jump: true,
                    coping: true,
                    homePage: '',
                    endPage: '',
                    current: indexs || 1,
                    callback: function (index) {
                        mes.data.page = index.getCurrent();
                        mes.page();
                    }
                });
            }
        };
        ajaxPageLe.page();
    }

    (function dep_user_select() {
        $("#selectDept").on("click", function () {
            dept_id = 'deptment';
            $.popWindow("../../common/selectDept?allDept=1");
        });

        function clearDept() {
            $('#deptment').removeAttr('deptid');
            $('#deptment').attr('dataid', '');
            $('#deptment').removeAttr('deptno');
            $('#deptment').val('');
        }

        $('#clearDept').click(function () {
            clearDept();
        });
        $("#selectUser").on("click", function () {
            user_id = 'userDuser';
            $.popWindow("../../common/selectUser");
        });

        function clearUser() {
            $('#userDuser').attr('user_id', '');
            $('#userDuser').attr('userprivname', '');
            $('#userDuser').removeAttr('dataid');
            $('#userDuser').val('');
        }

        $('#clearUser').click(function () {
            clearUser();
        });
    })();
    $(function () {
        $.ajax({
            type: 'get',
            url: "/code/getCode",
            data: {"parentNo": "PROJECT_NAME"},
            success: function (data) {
                for (var x = 0; x < data.obj.length; x++) {
                    $(".project").append("<option id=" + data.obj[x]["codeId"] + ">" + data.obj[x]["codeName"] + "</optionid>");
                }
            }
        });
        $.ajax({
            type: 'get',
            url: "/code/getCode",
            data: {"parentNo": "LOCATION_ADDRESS"},
            success: function (data) {
                for (var x = 0; x < data.obj.length; x++) {
                    $(".location").append("<option id=" + data.obj[x]["codeId"] + ">" + data.obj[x]["codeName"] + "</option>");
                }
            }
        });
        $.ajax({
            type: 'get',
            url: "/hrPersonnelScheduling/getUserPost",
            success: function (data) {
                for (var x = 0; x < data.obj.length; x++) {
                    $("#jobPosition").append("<option id=" + data.obj[x]['postId'] + ">" + data.obj[x]["postName"] + "</option>");
                }
            }
        });
        $.ajax({
            type: 'get',
            url: "/hrPersonnelScheduling/getUserJob",
            success: function (data) {
                for (var x = 0; x < data.obj.length; x++) {
                    $("#workJob").append("<option id=" + data.obj[x]['jobId'] + ">" + data.obj[x]["jobName"] + "</option>");
                }
            }
        });
        var projectInp = document.getElementsByClassName("project")[0];
        var locationInp = document.getElementsByClassName("location")[0];
        var jobPosition = document.getElementById("jobPosition");
        var workJob = document.getElementById("workJob");
        $("#checkOut").click(function () {
            var projectIndex = projectInp.selectedIndex;
            projectValue = projectInp.options[projectIndex].id;
            var locationIndex = locationInp.selectedIndex;
            locationValue = locationInp.options[locationIndex].id;
            var projectIndex = projectInp.selectedIndex;
            var locationIndex = locationInp.selectedIndex;
            var jobPositionIndex = jobPosition.selectedIndex;
            var workJobIndex = workJob.selectedIndex;

            var projectValue = projectInp.options[projectIndex].id;
            var locationValue = locationInp.options[locationIndex].id;
            var jobPositionValue;
            if (jobPosition.options[jobPositionIndex].value == '请选择..') {
                jobPositionValue = '';
            } else {
                jobPositionValue = jobPosition.options[jobPositionIndex].id;
                console.log("jobPositionValue",jobPositionValue);
            }
            var workJobValue = workJob.options[workJobIndex].id;
            var data1 = {
                projectName: projectValue,                        //ok
                deptId: $("#deptment").attr('deptid'),           //ok
                position: jobPositionValue,           //position
                workJob: workJobValue,                    //post
                locationAddress: locationValue,                  //ok
                userId: $("#userDuser").attr('user_id')          //ok
            };
            ajaxReAjax(data1);
            $.layerMsg({content: '查询成功！', icon: 1});
        });
    });
</script>
</html>